#环境:centos6.5i386 i386
#参见:
#在按照:
#email0dot0@163.com@http://yunpan.360.cn\root\install_and_config\nginx\read_me.txt
#安装好nginx1.6.0之后
#安装php-5.4.8
#文件编写风格:禁止大量使用cd, 禁止将&&写在行首。&&写在行首影响观赏性，&&写的行尾可能会忘记写，看自己选择。
#此脚本没有检测php的依赖项是否已经安装，只适合于刚刚安装好操作系统的情况下使用

#!/bin/sh
#PkRepo:package repository : 安装包存放目录
#DestHm:destination home : 目标安装目录
#LdCfHm:ld conf home : 

PkRepo=/usr/tmpx/install/php_after_nginx/pack_repo
UnpkHm=/usr/tmpx/install/php_after_nginx/unpack_home
LdCfHm="/etc/ld.so.conf.d/"
DestHm=/usr/local/

# init
test -d $PkRepo && \
rm -fr $UnpkHm && mkdir -p $UnpkHm && \
cd /tmp && \
export progress=begin && \
true

# install curl
test $progress == "begin" && \
PackFull=curl-7.32.0 && PackSimple=curl && \
export progress="begin_install_$PackFull" && \
rm -fr $UnpkHm/$PackFull && tar zxf $PkRepo/$PackFull.tar.gz -C $UnpkHm && cd $UnpkHm/$PackFull && \
./configure && make && make install && \
ldconfig && ldconfig -p | grep ${PackSimple} && \
export progress="end_install_$PackFull" && \
cd /tmp && true

# install libiconv
test $progress == "end_install_$PackFull" && \
PackFull=libiconv-1.13.1 && PackSimple=libiconv && \
export progress="begin_install_$PackFull" && \
rm -fr $UnpkHm/$PackFull && tar zxf $PkRepo/$PackFull.tar.gz -C $UnpkHm && cd $UnpkHm/$PackFull && \
./configure && make && make install && \
ldconfig && ldconfig -p | grep ${PackSimple} && \
export progress="end_install_$PackFull" && \
cd /tmp && true

# install php
test $progress == "end_install_$PackFull" && \
PackFull=php-5.4.8 && PackSimple=php && \
export progress="begin_install_$PackFull" && \
rm -fr $UnpkHm/$PackFull && tar zxf $PkRepo/$PackFull.tar.gz -C $UnpkHm && cd $UnpkHm/$PackFull && \
./configure\
 --prefix=/usr/local/php-5.4.8\
 --with-iconv-dir=/root/install/php/libiconv-1.13.1\
 --enable-fpm\
 --with-fpm-user=UserNginx\
 --with-fpm-group=GroupNginx\
 --with-config-file-path=/usr/local/php-5/etc/&&\
make ZEND_EXTRA_LIBS='-liconv' && make install && \
cd /usr/local/php-5.4.8/etc/ && mv php-fpm.conf.default php-fpm.conf && \
cp $UnpkHm/php-5.4.8/php.ini-production /usr/local/php-5.4.8/etc/php.ini && \
ldconfig && ldconfig -p | grep ${PackSimple} && \
export progress="end_install_$PackFull" && \
cd /tmp && true

 #启动php
# /usr/local/php-5.4.8/sbin/php-fpm

# server配置的目录 所有者设为 UserNginx
# chown -R UserNginx /var/dokuwiki
